package com.hdw.server.notice.service.impl;

import com.hdw.api.base.system.service.IHelloService;
import com.hdw.api.notice.service.IHelloNoticeService;
import com.hdw.common.core.utils.ShiroUtil;
import com.hdw.common.core.vo.LoginUserVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.rpc.RpcContext;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: ltx
 * @Date: 2021/5/18 14:02
 * @Description:
 */
@Slf4j
@DubboService
public class HelloNoticeServiceImpl implements IHelloNoticeService {
    @Override
    public String say(String str) {// 获取客户端隐式传入的参数，用于框架集成，不建议常规业务使用
        String index = RpcContext.getContext().getAttachment("index");
        log.info("index...{}", index);
        LoginUserVo user = ShiroUtil.getUser();
//        LoginUserVo user = (LoginUserVo) RpcContext.getContext().getObjectAttachment("user");
        log.info("user...{}", user);
        log.info("say...{}", str);
        return "world";
    }

    @Override
    public Map<String, Object> eat(String str) {
        // 获取客户端隐式传入的参数，用于框架集成，不建议常规业务使用
        String index = RpcContext.getContext().getAttachment("index");
        log.info("index...{}", index);
        LoginUserVo user = ShiroUtil.getUser();
//        LoginUserVo user = (LoginUserVo) RpcContext.getContext().getObjectAttachment("user");
        log.info("user...{}", user);
        log.info("eat...{}", str);
        Map<String, Object> map = new HashMap<>();
        map.put("aa", 123);
        map.put("bb", 456);
        return map;
    }
}
